/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.aeso.betabit.util;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.ws.Endpoint;

/**
 *
 * @author Edson
 */
public class SOAP {
    
    private static final String ADDRESS = "http://localhost";
    private static final String CONTEXT = "betabit";
    private static final int PORT = 8082;
    
    private static String getEndpoint(String address, int port, String context, String service) {
        return String.format("%s:%d/%s/%s", address, port, context, service).toLowerCase().replace("impl", "");
    }
    
    public static void startup(Object... services) {
        try {
            for (Object service : services) {
                String serviceName = service.getClass().getSimpleName();
                String endpoint = SOAP.getEndpoint(ADDRESS, PORT, CONTEXT, serviceName);
                Endpoint.publish(endpoint, service);
            }
        } catch (Exception ex) {
            Logger.getLogger(RMI.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}